package com.equipmentRent.system.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.equipmentRent.system.domain.VO.ReturnRecordVo;
import com.equipmentRent.system.domain.VO.RtnRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.equipmentRent.system.mapper.ReturnRecordMapper;
import com.equipmentRent.system.domain.ReturnRecord;
import com.equipmentRent.system.service.IReturnRecordService;
import com.equipmentRent.common.core.text.Convert;

/**
 * 物品归还记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-28
 */
@Service
public class ReturnRecordServiceImpl extends ServiceImpl<ReturnRecordMapper,ReturnRecord> implements IReturnRecordService

{
    @Autowired
    private ReturnRecordMapper returnRecordMapper;

    /**
     * 查询物品归还记录
     * 
     * @param id 物品归还记录主键
     * @return 物品归还记录
     */
    @Override
    public ReturnRecord selectReturnRecordById(Long id)
    {
        return returnRecordMapper.selectReturnRecordById(id);
    }

    /**
     * 查询物品归还记录列表
     * 
     * @param returnRecord 物品归还记录
     * @return 物品归还记录
     */
    @Override
    public List<ReturnRecord> selectReturnRecordList(ReturnRecord returnRecord)
    {
        return returnRecordMapper.selectReturnRecordList(returnRecord);
    }

    /**
     * 新增物品归还记录
     * 
     * @param returnRecord 物品归还记录
     * @return 结果
     */
    @Override
    public int insertReturnRecord(ReturnRecord returnRecord)
    {
        return returnRecordMapper.insertReturnRecord(returnRecord);
    }

    /**
     * 修改物品归还记录
     * 
     * @param returnRecord 物品归还记录
     * @return 结果
     */
    @Override
    public int updateReturnRecord(ReturnRecord returnRecord)
    {
        return returnRecordMapper.updateReturnRecord(returnRecord);
    }

    /**
     * 批量删除物品归还记录
     * 
     * @param ids 需要删除的物品归还记录主键
     * @return 结果
     */
    @Override
    public int deleteReturnRecordByIds(String ids)
    {
        return returnRecordMapper.deleteReturnRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除物品归还记录
     *
     * @param ids 需要软删除的物品归还记录主键
     * @return 结果
     */
    @Override
    public int softDeleteReturnRecordByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            ReturnRecord returnRecord = returnRecordMapper.selectReturnRecordById(Long.valueOf(s));
            int i = returnRecordMapper.update(null, Wrappers.<ReturnRecord>lambdaUpdate()
                    .set(ReturnRecord::getIsDelete, 1L)
                    .eq(ReturnRecord::getId, returnRecord.getId()));
            count = count + i;
        }
        return count;
    }

    /**
     * 删除物品归还记录信息
     * 
     * @param id 物品归还记录主键
     * @return 结果
     */
    @Override
    public int deleteReturnRecordById(Long id)
    {
        return returnRecordMapper.deleteReturnRecordById(id);
    }

    @Override
    public List<RtnRecordVo> selectReturnRecordVoList(ReturnRecord returnRecord) {
        return returnRecordMapper.selectReturnRecordVoList(returnRecord);
    }
}
